Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: report read statistics to pd #2307

Merged
merged 26 commits into from Sep 27, 2017
Merged

*: report read statistics to pd #2307

merged 26 commits into from Sep 27, 2017

Conversation

nolouch
Copy link
Contributor

@nolouch nolouch commented Sep 18, 2017

report the read statistics.


impl<R> ContextFactory<CopContext<R>> for CopContextFactory<R>
where
R: RaftStoreRouter + 'static,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should not introduce RaftStoreRouter to the coprocessor, seem strange here.

You can define a trait which sending your read stats like storage raftkv does.

@@ -75,6 +76,8 @@ pub enum Msg {
// For snapshot stats.
SnapshotStats,

CoprocessorStats { request_stats: CopRequestStatistics },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad style to let raftstore import upper coprocessor mod.

@nolouch nolouch changed the title [DNM] *: report read statistics to pd *: report read statistics to pd Sep 22, 2017
pub type CopRequestStatistics = HashMap<u64, FlowStatistics>;

pub trait CopSender: Send + Clone {
fn send(&self, CopRequestStatistics) -> RaftStoreResult<()>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use your own Cop Result, don't use RaftStoreResult.
IMO, you should only know RaftStore in server mod

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm, CopResult also needs use raftstore mod, for implement From from the RaftStoreResult. I'm going to extract the PD work in another pr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to support From, you can use box_try or if let Err(e) = + format! to return your own error.

@siddontang
Copy link
Contributor

LGTM

But I suggest sending read statistics to the PD worker directly later.

PTAL @BusyJay @zhangjinpeng1987


fn add_statistics_by_request(&mut self, id: u64, stats: &Statistics) {
let empty_stat = FlowStatistics::default();
let flow_stats = self.request_stats.entry(id).or_insert(empty_stat);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/empty_stat/FlowStatistics::default()

@@ -91,9 +117,16 @@ impl CopContext {
}
}
}

fn add_statistics_by_request(&mut self, id: u64, stats: &Statistics) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id == region_id ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/add_statistics_by_request/add_statistics_by_region


}

fn on_report_store_flow(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too complicated to understand.

Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


impl<R: RaftStoreRouter + 'static> CopSender for CopReport<R> {
fn send(&self, stats: CopRequestStatistics) -> CopResult<()> {
box_try!(self.router.send(Msg::CoprocessorStats {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use try_send here

@siddontang
Copy link
Contributor

LGTM

CI failed @nolouch

@nolouch nolouch merged commit a551563 into master Sep 27, 2017
@nolouch nolouch deleted the shuning/readbytes branch September 27, 2017 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants